package io.renren.modules.sys.controller;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.vo.RV;
import io.renren.modules.sys.entity.DicGroup;
import io.renren.modules.sys.service.DicGroupService;



/**
 * 应用字典分组表
 *
 * @author jingtang
 * @email sunlightcs@gmail.com
 * @date 2018-06-28 08:41:11
 */
@RestController
@RequestMapping("sys/dicgroup")
public class DicGroupController extends AbstractController {
    @Autowired
    private DicGroupService dicGroupService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:dicgroup:list")
    public RV list(@RequestParam Map<String, Object> params){
        

        return RV.ok();
    }
    
    @PostMapping("/tree")
    @RequiresPermissions("sys:dicgroup:tree")
    public RV tree(@RequestParam Map<String, Object> params){
        

        return RV.ok(dicGroupService.getDicGroupTree());
    }
    
    //


    /**
     * 信息
     */
    @RequestMapping("/info/{dicGpId}")
    @RequiresPermissions("sys:dicgroup:info")
    public RV info(@PathVariable("dicGpId") String dicGpId){
		DicGroup dicGroup = dicGroupService.selectById(dicGpId);

        return RV.ok(dicGroup);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:dicgroup:save")
    public RV save(@RequestBody DicGroup dicGroup){

        return RV.ok(dicGroupService.saveDicGroup(dicGroup));
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:dicgroup:update")
    public RV update(@RequestBody DicGroup dicGroup){
			dicGroupService.updateById(dicGroup);

        return RV.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{dicGpId}")
    @RequiresPermissions("sys:dicgroup:delete")
    public RV delete(@PathVariable String dicGpId){
			dicGroupService.deleteDicGp(dicGpId);

        return RV.ok();
    }

}
